{extend name="public/base"}

{block name="title"}权限列表{/block}

{block name="main"}
<!-- 搜索表单 -->
<form action="{:url('/auth')}" class="pb-3">
    <div class="form-row">
        <div class="col-form-label">
            <label for="name">管理员: </label>
        </div>
        <div class="col-auto">
            <input type="text" id="name" name="name" placeholder="查询的管理员" class="form-control">
        </div>
        <div class="col-auto">
            <button class="btn btn-primary">搜索</button>
            <a href="{:url('/auth/create')}" class="btn btn-success">添加管理</a>
        </div>
    </div>
</form>
<!-- 数据列表 -->
<table class="table table-bordered">
    <thread class="bg-light">
        <tr>
            <th class="text-center">ID</th>
            <th>用户名</th>
            <th>权限范围</th>
            <th class="text-center">操作</th>
        </tr>
    </thread>
    <tbody>
    {assign name="empty" value='<tr><td colspan="7" class="text-center text-muted">没有数据</td></tr>'}
    {volist name="list" id="obj" empty="$empty"}
    <tr>
        <td class="text-center">{$obj.id}</td>
        <td>{$obj.name}</td>
        <td>{$obj.roles}</td>
        <td class="text-center">
            <form action="{:url('/auth/' . $obj.id)}" method="post">
                <input type="hidden" name="_method" value="delete">
                <button class="btn btn-danger btn-sm btn-delete">删除</button>
                <a href="{:url('/auth/' . $obj.id . '/edit')}" class="btn btn-warning btn-sm">修改</a>
            </form>
        </td>
    </tr>
    {/volist}
    </tbody>
</table>
<!-- 分页 -->
{$list|raw}
{/block}

{block name="js"}
<script type="text/javascript">
    $('.btn-delete').click(() => {
        let flag = confirm('您真的要删除这条数据吗?');
        return flag ? true : false;
    });
    $('[data-toggle="tooltip"]').tooltip();
</script>
{/block}